//
//  ThemeColor.swift
//  Wanbair
//
//  Created by Li on 2025/3/7.
//

import UIKit

extension UIColor {
    
    /// 根据主题读取颜色
    /// - Parameter color: ThemeManager.shared.currentTheme.backgroundColor
    /// - Returns: color
    static func themeColor(hex color: String) -> UIColor {
        return ThemeManager.shared.currentTheme.colorFromHex(color)
    }
    
    static var themeColor: UIColor {
        return ThemeManager.shared.currentTheme.colorFromHex(ThemeManager.shared.currentTheme.backgroundColor)
    }
    
    
    static var themeBackgroundColor: UIColor {
        return ThemeManager.shared.currentTheme.colorFromHex(ThemeManager.shared.currentTheme.backgroundColor)
    }
    
    static var themeNavColor: UIColor {
        return ThemeManager.shared.currentTheme.colorFromHex(ThemeManager.shared.currentTheme.navBgColor)
    }
    
    static var themeBtnColor: UIColor {
        return ThemeManager.shared.currentTheme.colorFromHex(ThemeManager.shared.currentTheme.buttonColor)

    }

    static var themePlaceholdColor: UIColor {
        return ThemeManager.shared.currentTheme.colorFromHex(ThemeManager.shared.currentTheme.placeholdColor)

    }
    
    static var themeTextFieldColor: UIColor {
        return ThemeManager.shared.currentTheme.colorFromHex(ThemeManager.shared.currentTheme.textFieldColor)
    }
    
}


extension UIImage {
    
    static func themeImage(named imageName: String) -> UIImage? {
        // 构建图片路径：Resources/{ThemeName}/{imageName}
        let imagePath = "\(imageName)_\(ThemeManager.shared.currentTheme.name)"
        return UIImage(named: imagePath)
    }
    
}
